package com.new2i.service.impl;

import java.util.HashMap; 

import org.springframework.stereotype.Service;

import com.new2i.model.SmsEntity;
import com.new2i.service.able.SmsService;
import com.new2i.util.RegexUtil;
import com.new2i.util.SmsSendUtil;

/**
 * 短信业务逻辑处理实现类
 * 
 * @author 2i
 * @since 2015/09/06
 */
@Service("SmsService")
public class SmsServiceImpl implements SmsService {

	@Override
	public HashMap<String, Object> sendSms(String mobile, String content) {
		HashMap<String, Object> rHashMap = new HashMap<String, Object>();
		if (mobile == null) {
			rHashMap.put("code", 311);
			rHashMap.put("err_msg", "手机号码不能为空");
			return rHashMap;
		}
		if (!RegexUtil.validatePhoneNum(mobile)) {
			rHashMap.put("code", 314);
			rHashMap.put("err_msg", "手机号码格式不正确");
			return rHashMap;
		}
		String result = SmsSendUtil.sendSms(mobile, content);
		rHashMap.put("msg", result);
		return rHashMap;
	}

	@Override
	public HashMap<String, Object> insertSms(SmsEntity sms) {
		HashMap<String, Object> rHashMap = new HashMap<String,Object>();

		return rHashMap;
	}

	@Override
	public HashMap<String, Object> selectSmsListByDU(SmsEntity sms) {
		HashMap<String, Object> rHashMap = new HashMap<String,Object>();
		return rHashMap;
	} 

}
